/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function(nums) {
  let count = 1;
  for(let i = 1; i < nums.length; i++) {
    if(nums[i] == nums[i - 1]) {
      if(count == 2) {
        nums.splice(i, 1);
        i--;
      } else {
        count++;
      }
    } else {
      count = 1;
    }
  }
};
let nums = [1,1,1,2,2,3];
console.log(removeDuplicates(nums));
nums = [0,0,1,1,1,1,2,3,3];
console.log(removeDuplicates(nums));
